<template>
    <section class="forget">
        <div class="form-box">
            <div class="form-group mb20">
                <label class="label-icon">
                    <img src="../../assets/images/ioc_1.png" />
                </label>
                <div class="input-group">
                    <input type="text" placeholder="请输入用户名" class="input input-login" v-model="name">
                </div>
            </div>
            <div class="form-group mb20">
                <label class="label-icon">
                    <img src="../../assets/images/ioc_1.png" />
                </label>
                <div class="input-group">
                    <input type="text" placeholder="请输入密码" class="input input-login" v-model="npwd">
                </div>
            </div>
            <div class="form-group">
                <label class="label-icon">
                    <img src="../../assets/images/ioc_2.png" />
                </label>
                <div class="input-group">
                    <input type="pwdType" placeholder="请确定密码" class="input input-login" v-model="spwd">
                </div>
            </div>
        </div>
        <div class="btn-group">
            <button class="btn btn-default login-btn" @click="changepwd()">确认</button>
        </div>
    </section>
</template>

<script>
    import forgetService from "../../service/forget";
    export default {
        data() {
            return {
                name:"",
                npwd:"",
                spwd:""
            }
        },
        methods : {
                changepwd(){
                    if(this.name == "") {
                        alert("请输入用户名");
                        return;
                    } else if(this.npwd == "") {
                        alert("请输入密码");
                        return;
                    } else if(this.spwd == "") {
                        alert("请确认密码");
                        return;
                    } else if(this.npwd != this.spwd){
                        alert("密码不一致请重新输入");
                        return;
                    }
                    var params = {
                        name:this.name,
                        npwd:this.npwd,
                        spwd:this.spwd
                    }
                    forgetService.forget(params)
                    .then(res => {
                        if(res){
                            if(res.ret == "0000") {
                                alert("修改成功");
                                this.$router.push({"path":"/login"});
                            } else {
                                alert(res.msg);
                            }
                        }
                    });

                }
        }
    }
</script>

<style>

</style>
